//
//  MySelfController.m
//  YiBaoStore
//
//  Created by 毛云河 on 2018/10/1.
//  Copyright © 2018年 小河. All rights reserved.
//

#import "MySelfController.h"
#import "CapitalFlowController.h"
#import "PickUpViewController.h"
#import "OrderViewController.h"
#import "BasicWebViewController.h"
#import "BalanceDetailController.h"
#import "ShopInfoViewController.h"
#import "DownLoadCodeViewController.h"

@interface MySelfController ()

@property (nonatomic, strong) UIScrollView *mainScroll;
@property (nonatomic, strong) NSDictionary *dict;
@property (nonatomic, strong) NSDictionary *infoDict;
@property (nonatomic, strong) UIButton *bailBtn; //保证金充值
@property (nonatomic, assign) BOOL isOrderRechargeAmount; //是否提示货款不足
@property (nonatomic, assign) BOOL isFronze; //是否有冻结订单
@property (nonatomic, strong) PickUpViewController *pickVC;
@end

@implementation MySelfController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.bgNavView.hidden = YES;
    [self setMainView];
    //刷新金钱的值
    //[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(refreshMoney:) name:RefreshMoney object:nil];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self getNetWorkData];
}

- (void)getNetWorkData
{
    self.dict = [NSDictionary dictionary];
    self.infoDict = [NSDictionary dictionary];
    [[HttpRequest currentHttpRequest]postPath:MySelfIndex_API params:nil resultBlock:^(id Data, MsgModel *msgModel) {
        self.dict = [NSDictionary dictionaryWithDictionary:Data];
        NSLog(@"dict--%@",self.dict);
        dispatch_async(dispatch_get_main_queue(), ^{
            [self setMainView];
            [self updateMsg:self.dict];
        });
        [self.mainScroll.mj_header endRefreshing];
    }];
}

#pragma mark -- 更新信息
- (void)updateMsg:(NSDictionary *)data
{
    UIImageView *logo = (UIImageView *)[self.view viewWithTag:20];
    UILabel *nameLab = (UILabel *)[self.view viewWithTag:21];
    UILabel *balanceLab = (UILabel *)[self.view viewWithTag:50];
    UIImageView *arrow = (UIImageView*)[self.view viewWithTag:23];
    UILabel *moneyLab = (UILabel *)[self.view viewWithTag:24];
    NSDictionary *dict = data[@"orderStateStatistics"];
    UIView *orderView = (UIView *)[self.view viewWithTag:111];
    UIView *titleView = (UIView *)[self.view viewWithTag:300];
    self.infoDict = data[@"shopInfo"];
    [logo sd_setImageWithURL:[NSURL URLWithString:self.infoDict[@"logo"]] placeholderImage:[UIImage imageNamed:@"Placeholder100"]];
    nameLab.text = [NSString stringWithFormat:@"%@",self.infoDict[@"name"]];
    balanceLab.text = [NSString stringWithFormat:@"%.2f",[data[@"goodsCapitalAmount"]doubleValue]];
    [balanceLab sizeToFit];
    
    if ([data[@"goodsCapitalAmountNeedForConfirmOrder"]doubleValue]>0.00) {
        moneyLab.hidden = NO;
        //余额不足，请及时充值112元解冻所有冻结
        moneyLab.text = [NSString stringWithFormat:@"余额不足，请及时充值%.2f元解冻所有冻结订单",[data[@"goodsCapitalAmountNeedForConfirmOrder"]doubleValue]];
    }else
    {
        moneyLab.hidden = YES;
    }
    CGSize size = [TTKUtil sizeWithText:balanceLab.text Height:28 Font:FontSemiboldSize(20)];
    arrow.left = balanceLab.left+size.width+10;
    
    [orderView removeFromSuperview];
    UIView *newView = [UIView new];
    newView.tag = 111;
    newView.frame = CGRectMake(0, titleView.bottom, SCREENWIDTH, 73);
    [self.mainScroll addSubview:newView];
    NSArray *imageArray = nil;
    NSArray *orderTitleArray = nil;
    if ([dict[@"waitForConfirmByGoodsCapitalCount"]integerValue] > 0) {
        imageArray = @[@"freeze",@"noPay",@"noDelever",@"pay"];
        orderTitleArray = @[@"冻结",@"待取货",@"待发货",@"待收货"];
    }
    else
    {
        imageArray = @[@"noPay",@"noDelever",@"pay"];
        orderTitleArray = @[@"待取货",@"待发货",@"待收货"];
    }
    //如果没有冻结订单
    CGFloat orderWidth = SCREENWIDTH/imageArray.count;
    CGFloat padding = (orderWidth-40)/2.0;
    for (NSInteger i = 0; i < imageArray.count; i++)
    {
        UIImageView *ordIV = [UIImageView new];
        ordIV.frame = CGRectMake(orderWidth*i+padding, 0, 40, 40);
        ordIV.image = [UIImage imageNamed:imageArray[i]];
        ordIV.userInteractionEnabled = YES;
        ordIV.contentMode = UIViewContentModeScaleAspectFill;
        [newView addSubview:ordIV];
        UILabel *desLab = [UILabel new];
        desLab.frame = CGRectMake(orderWidth*i, ordIV.bottom+8,orderWidth, 12);
        desLab.textColor = titleColor;
        desLab.font = FontWithSize(12);
        desLab.userInteractionEnabled = YES;
        desLab.tag = 25+i;
        desLab.textAlignment = NSTextAlignmentCenter;
        desLab.text = orderTitleArray[i];
        [newView addSubview:desLab];
        UIButton *orderBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        orderBtn.frame = CGRectMake(orderWidth*i, 0, orderWidth, orderView.height);
        orderBtn.backgroundColor = [UIColor clearColor];
        orderBtn.tag = 200+i;
        [orderBtn addTarget:self action:@selector(goToOrderVC:) forControlEvents:UIControlEventTouchUpInside];
        [newView addSubview:orderBtn];
        
        if ([dict[@"waitForConfirmByGoodsCapitalCount"]integerValue] > 0) {
            self.isFronze = YES;
            if (i == 0) {
                desLab.text = [NSString stringWithFormat:@"冻结(%d)",[dict[@"waitForConfirmByGoodsCapitalCount"]intValue]];
            }
            else if(i == 1 && [dict[@"waitForPickUpCount"]integerValue] != 0)
            {
                desLab.text = [NSString stringWithFormat:@"待取货(%d)",[dict[@"waitForPickUpCount"]intValue]];
            }else if ( i == 2 && [dict[@"waitForDeliveryCount"]integerValue] != 0)
            {
                desLab.text = [NSString stringWithFormat:@"待发货(%d)",[dict[@"waitForDeliveryCount"]intValue]];
            }
            else if(i == 3 && [dict[@"waitForReceiveCount"]integerValue] != 0)
            {
                desLab.text = [NSString stringWithFormat:@"待收货(%d)",[dict[@"waitForReceiveCount"]intValue]];
            }
        }
        else
        {
            self.isFronze = NO;
            if(i == 0 && [dict[@"waitForPickUpCount"]integerValue] != 0)
            {
                desLab.text = [NSString stringWithFormat:@"待取货(%d)",[dict[@"waitForPickUpCount"]intValue]];
            }else if ( i == 1 && [dict[@"waitForDeliveryCount"]integerValue] != 0)
            {
                desLab.text = [NSString stringWithFormat:@"待发货(%d)",[dict[@"waitForDeliveryCount"]intValue]];
            }
            else if(i == 2 && [dict[@"waitForReceiveCount"]integerValue] != 0)
            {
                desLab.text = [NSString stringWithFormat:@"待收货(%d)",[dict[@"waitForReceiveCount"]intValue]];
            }
        }
    }
    UIView *orderLine = [UIView new];
    orderLine.frame = CGRectMake(15, orderView.height-1, SCREENWIDTH-30, 1);
    orderLine.backgroundColor = UIColorFromHex(0xF8F8F8);
    [orderView addSubview:orderLine];
}

- (void)setMainView
{
    if (self.mainScroll == nil)
    {
        self.mainScroll = [UIScrollView new];
        if (@available(iOS 11.0, *)) {
            self.mainScroll.frame = CGRectMake(0, TopBarHeight_xs, SCREENWIDTH, SCREENHEIGHT-TopBarHeight_xs-BottomHeight_xs-49);
        } else {
            // Fallback on earlier versions
            self.mainScroll.frame = CGRectMake(0, TopBarHeight, SCREENWIDTH, SCREENHEIGHT-TopBarHeight-BottomHeight-49);
        }
        self.mainScroll.backgroundColor = TotalWhite;
        self.mainScroll.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(getNetWorkData)];
        [self.view addSubview:self.mainScroll];
        
        UIImageView *shopIV = [UIImageView new];
        shopIV.frame = CGRectMake(15, 0, 44, 44);
        shopIV.layer.cornerRadius = 22;
        shopIV.layer.masksToBounds = YES;
        shopIV.tag = 20;
        shopIV.image = [UIImage imageNamed:@"Placeholder100"];
        [self.mainScroll addSubview:shopIV];
        
        UIButton *shopBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        shopBtn.frame = CGRectMake(15, 0, 44, 44);
        [shopBtn addTarget:self action:@selector(editInfo:) forControlEvents:UIControlEventTouchUpInside];
        [self.mainScroll addSubview:shopBtn];
        
        UIImageView *arrowIV = [UIImageView new];
        arrowIV.frame = CGRectMake(SCREENWIDTH-15-18, shopIV.top+14, 18, 18);
        arrowIV.image = [UIImage imageNamed:@"shopMore"];
        [self.mainScroll addSubview:arrowIV];
        
        UIButton *moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        moreBtn.frame = CGRectMake(arrowIV.left-8, arrowIV.top-8, 34, 34);
        moreBtn.backgroundColor = [UIColor clearColor];
        [moreBtn addTarget:self action:@selector(editInfo:) forControlEvents:UIControlEventTouchUpInside];
        [self.mainScroll addSubview:moreBtn];
        
        UILabel *shopLab = [UILabel new];
        CGFloat width = SCREENWIDTH-shopIV.right-10-40;
        shopLab.frame = CGRectMake(shopIV.right+10, shopIV.top+13, width, 18);
        shopLab.textColor = UIColorFromHex(0x343434);
        shopLab.font = FontSemiboldSize(18);
        shopLab.tag = 21;
        shopLab.text = @"异宝全球购";
        [self.mainScroll addSubview:shopLab];
        
        //充值与金额
        UIImageView *moneyBackIV = [UIImageView new];
        moneyBackIV.frame = CGRectMake(15, shopIV.bottom+20, SCREENWIDTH-30, 110);
        moneyBackIV.image = [UIImage imageNamed:@"payBack"];
        moneyBackIV.userInteractionEnabled = YES;
        [self.mainScroll addSubview:moneyBackIV];
        
        UILabel *moneyLab = [UILabel new];
        moneyLab.frame = CGRectMake(15, 20, 170, 28);
        moneyLab.textColor = TotalWhite;
        moneyLab.font = FontSemiboldSize(20);
        moneyLab.tag = 50;
        moneyLab.text = @"0.00";
        [moneyBackIV addSubview:moneyLab];
        
        CGSize size = [TTKUtil sizeWithText:moneyLab.text Height:28 Font:FontSemiboldSize(20)];
        moneyLab.width = size.width;
        UIImageView *moneyRightIV = [UIImageView new];
        moneyRightIV.frame = CGRectMake(moneyLab.right+5, 25, 18, 18);
        moneyRightIV.tag = 23;
        moneyRightIV.image = [UIImage imageNamed:@"shopMore"];
        [moneyBackIV addSubview:moneyRightIV];
        
        UIButton *detailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        detailBtn.frame = CGRectMake(moneyLab.left, moneyLab.top, moneyLab.width+5+25, 28);
        detailBtn.backgroundColor = [UIColor clearColor];
        [detailBtn addTarget:self action:@selector(goToDetails:) forControlEvents:UIControlEventTouchUpInside];
        [moneyBackIV addSubview:detailBtn];
        
        UIImageView *leftIV = [UIImageView new];
        leftIV.frame = CGRectMake(moneyLab.left, moneyLab.bottom+10, 15, 12);
        leftIV.image = [UIImage imageNamed:@"myBalance"];
        [moneyBackIV addSubview:leftIV];
        
        UILabel *desLab = [UILabel new];
        desLab.frame = CGRectMake(leftIV.right+5, leftIV.top-1, 84, 14);
        desLab.textColor = UIColorFromHex(0x898989);
        desLab.font = FontWithSize(12);
        desLab.text = @"余额（元)";
        [moneyBackIV addSubview:desLab];
        
        UILabel *tipLab = [UILabel new];
        tipLab.frame = CGRectMake(moneyLab.left, desLab.bottom+4, moneyBackIV.width, 12);
        tipLab.textColor = UIColorFromHex(0xE15335);
        tipLab.font = FontMediumWithSize(12);
        tipLab.tag = 24;
        tipLab.text = @"余额不足，请及时充值112元解冻所有冻结订单";
        tipLab.hidden = YES;
        [moneyBackIV addSubview:tipLab];
        
        //余额充值
        UIButton *rechargeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        rechargeBtn.frame = CGRectMake(moneyBackIV.width-95, 30, 80, 30);
        rechargeBtn.backgroundColor = UIColorFromHex(0x3B3B3B);
        rechargeBtn.layer.cornerRadius = 8;
        rechargeBtn.layer.masksToBounds = YES;
        rechargeBtn.layer.borderWidth = 1;
        rechargeBtn.tag = 88;
        rechargeBtn.layer.borderColor = UIColorFromHex(0xEED15B).CGColor;
        rechargeBtn.titleLabel.font = FontWithSize(14);
        [rechargeBtn setTitleColor:UIColorFromHex(0xF3F3F3) forState:UIControlStateNormal];
        [rechargeBtn setTitle:@"充值" forState:UIControlStateNormal];
        [rechargeBtn addTarget:self action:@selector(rechargeBtn:) forControlEvents:UIControlEventTouchUpInside];
        [moneyBackIV addSubview:rechargeBtn];
        /* //保证金
        UILabel *bailLab = [UILabel new];
        bailLab.frame = CGRectMake(moneyLab.left, desLab.bottom+36, 100, 14);
        bailLab.textColor = TotalWhite;
        bailLab.font = FontSemiboldSize(14);
        bailLab.text = @"100.00";
        [moneyBackIV addSubview:bailLab];
        
        UIImageView *bailIV = [UIImageView new];
        bailIV.frame = CGRectMake(17, bailLab.bottom+10, 11, 12);
        bailIV.backgroundColor = [UIColor orangeColor];
        [moneyBackIV addSubview:bailIV];
        
        UILabel *desBailLab = [UILabel new];
        desBailLab.frame = CGRectMake(bailIV.right+5, bailLab.bottom+9, 72, 14);
        desBailLab.textColor = UIColorFromHex(0x898989);
        desBailLab.font = FontWithSize(12);
        desBailLab.text = @"保证金（元）";
        [moneyBackIV addSubview:desBailLab];
        
        //保证金充值
        UIButton *bailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        bailBtn.frame = CGRectMake(moneyBackIV.width-95, rechargeBtn.bottom+36, 80, 30);
        bailBtn.backgroundColor = UIColorFromHex(0x3B3B3B);
        bailBtn.layer.cornerRadius = 8;
        bailBtn.layer.masksToBounds = YES;
        bailBtn.layer.borderWidth = 1;
        bailBtn.tag = 89;
        bailBtn.layer.borderColor = UIColorFromHex(0xEED15B).CGColor;
        bailBtn.titleLabel.font = FontWithSize(14);
        [bailBtn setTitleColor:UIColorFromHex(0xF3F3F3) forState:UIControlStateNormal];
        [bailBtn setTitle:@"充值" forState:UIControlStateNormal];
        [bailBtn addTarget:self action:@selector(rechargeBtn:) forControlEvents:UIControlEventTouchUpInside];
        [moneyBackIV addSubview:bailBtn];
        //中间的view
        UIView *moneyLineV = [UIView new];
        moneyLineV.frame = CGRectMake(0, moneyBackIV.bottom+15, SCREENWIDTH, 9);
        moneyLineV.backgroundColor = UIColorFromHex(0xF0F0F0);
        [self.mainScroll addSubview:moneyLineV];
        
        //资金流水
        UIView *flowView = [UIView new];
        flowView.frame = CGRectMake(0, moneyLineV.bottom, moneyLineV.width, 49);
        flowView.backgroundColor = TotalWhite;
        flowView.userInteractionEnabled = YES;
        [self.mainScroll addSubview:flowView];
        
        UILabel *flowLab = [UILabel new];
        flowLab.frame = CGRectMake(15, 15, 80, 20);
        flowLab.textColor = titleColor;
        flowLab.font = FontSemiboldSize(14);
        flowLab.text = @"资金流水";
        [flowView addSubview:flowLab];
        
        UIImageView *flowIV = [UIImageView new];
        flowIV.frame = CGRectMake(flowView.width-33, 16, 18, 18);
        flowIV.image = [UIImage imageNamed:@"shopMore"];
        [flowView addSubview:flowIV];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(capitalFlow:)];
        [flowView addGestureRecognizer:tap];
        
        UIView *flowLineV = [UIView new];
        flowLineV.frame = CGRectMake(0, flowView.bottom, SCREENWIDTH, 9);
        flowLineV.backgroundColor = UIColorFromHex(0xF0F0F0);
        [self.mainScroll addSubview:flowLineV];
        */
        
        //店铺订单
        UIView *orderTitleView = [UIView new];
        orderTitleView.tag = 300;
        orderTitleView.frame = CGRectMake(0, moneyBackIV.bottom+20, SCREENWIDTH, 35);
        orderTitleView.backgroundColor = TotalWhite;
        orderTitleView.userInteractionEnabled = YES;
        [self.mainScroll addSubview:orderTitleView];
        
        UITapGestureRecognizer *orderTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(orderTap:)];
        [orderTitleView addGestureRecognizer:orderTap];
        
        UILabel *orderLab = [UILabel new];
        orderLab.frame = CGRectMake(15, 0, 60, 20);
        orderLab.textColor = titleColor;
        orderLab.font = FontSemiboldSize(14);
        orderLab.text = @"店铺订单";
        [orderTitleView addSubview:orderLab];
        
        UIImageView *orderIV = [UIImageView new];
        orderIV.frame = CGRectMake(SCREENWIDTH-33, 1, 18, 18);
        orderIV.image = [UIImage imageNamed:@"shopMore"];
        [orderTitleView addSubview:orderIV];
        //查看全部订单
        UILabel *showAllLab = [UILabel new];
        showAllLab.frame = CGRectMake(orderIV.left-90, 0, 85, 20);
        showAllLab.textColor = titleColor;
        showAllLab.font = FontWithSize(14);
        showAllLab.text = @"查看全部订单";
        [orderTitleView addSubview:showAllLab];
        
        //多种订单
        UIView *orderView = [UIView new];
        orderView.frame = CGRectMake(0, orderTitleView.bottom, SCREENWIDTH, 73);
        orderView.tag = 111;
        orderView.backgroundColor = TotalWhite;
        [self.mainScroll addSubview:orderView];
        NSArray *imageArray = @[@"freeze",@"noPay",@"noDelever",@"pay"];
        NSArray *orderTitleArray = @[@"冻结",@"待取货",@"待发货",@"待收货"];
        CGFloat orderWidth = SCREENWIDTH/imageArray.count;
        CGFloat padding = (orderWidth-40)/2.0;
        for (NSInteger i = 0; i < imageArray.count; i++)
        {
            UIImageView *ordIV = [UIImageView new];
            ordIV.frame = CGRectMake(orderWidth*i+padding, 0, 40, 40);
            ordIV.image = [UIImage imageNamed:imageArray[i]];
            ordIV.contentMode = UIViewContentModeScaleAspectFill;
            [orderView addSubview:ordIV];
            UILabel *desLab = [UILabel new];
            desLab.frame = CGRectMake(orderWidth*i, ordIV.bottom+8,orderWidth, 12);
            desLab.textColor = titleColor;
            desLab.font = FontWithSize(12);
            //desLab.tag = 25+i;
            desLab.textAlignment = NSTextAlignmentCenter;
            desLab.text = orderTitleArray[i];
            [orderView addSubview:desLab];
            UIButton *orderBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            orderBtn.frame = CGRectMake(orderWidth*i, 0, orderWidth, orderView.height);
            orderBtn.backgroundColor = ClearColor;
            //orderBtn.tag = 200+i;
            [orderBtn addTarget:self action:@selector(goToOrderVC:) forControlEvents:UIControlEventTouchUpInside];
            [orderView addSubview:orderBtn];
        }
        UIView *orderLine = [UIView new];
        orderLine.frame = CGRectMake(15, orderView.height-1, SCREENWIDTH-30, 1);
        orderLine.backgroundColor = UIColorFromHex(0xF8F8F8);
        [orderView addSubview:orderLine];
        
        //底部三个按钮
        CGFloat bottom = 0.0;
        NSArray *bottomArray = @[@"我的活动",@"帮助与客服",@"进入小程序",@"下载二维码",@"设置"];//
        for (int i = 0; i < bottomArray.count; i++)
        {
            UIView *view = [UIView new];
            view.frame = CGRectMake(0, orderView.bottom+60*i, SCREENWIDTH, 60);
            view.backgroundColor = TotalWhite;
            [self.mainScroll addSubview:view];
            
            UILabel *label = [UILabel new];
            label.frame = CGRectMake(15, 20, 70, 20);
            label.textColor = titleColor;
            label.font = FontSemiboldSize(14);
            label.text = bottomArray[i];
            [view addSubview:label];
            
            UIImageView *iv = [UIImageView new];
            iv.frame = CGRectMake(SCREENWIDTH-33, 21, 18, 18);
            iv.image = [UIImage imageNamed:@"shopMore"];
            [view addSubview:iv];
            
            UIImageView *line = [UIImageView new];
            line.frame = CGRectMake(15, view.height-1, SCREENWIDTH-30, 1);
            line.backgroundColor = UIColorFromHex(0xF8F8F8);
            [view addSubview:line];
            
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            btn.frame = CGRectMake(0, 0, view.width, view.height);
            btn.backgroundColor = ClearColor;
            [btn addTarget:self action:@selector(selectBtn:) forControlEvents:UIControlEventTouchUpInside];
            btn.tag = 30+i;
            [view addSubview:btn];
            bottom = view.bottom;
        }
        
        //取件按钮
        UIButton *pickBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        pickBtn.frame = CGRectMake(SCREENWIDTH-80, SCREENHEIGHT-BottomHeight-TabBarHeight-90, 65, 65);
        [pickBtn setBackgroundImage:[UIImage imageNamed:@"Group"] forState:UIControlStateNormal];
        [pickBtn setTitleColor:UIColorFromHex(0x3E3E3E) forState:UIControlStateNormal];
        [pickBtn setTitle:@"取件" forState:UIControlStateNormal];
        pickBtn.titleLabel.font = FontWithSize(22);
        [pickBtn addTarget:self action:@selector(pickBtn:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:pickBtn];
        
        self.mainScroll.contentSize = CGSizeMake(SCREENWIDTH, bottom+25);
    }
}

#pragma mark -- 取件按钮
- (void)pickBtn:(UIButton *)btn
{
    self.pickVC = [[PickUpViewController alloc]init];
//    [self.view addSubview:self.pickVC.view];
     [[UIApplication sharedApplication].windows[0] addSubview:self.pickVC.view];
    self.pickVC.view.frame = CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT);
}

#pragma mark -- 修改个人信息
- (void)editInfo:(UIButton *)btn
{
    ShopInfoViewController *editVC = [ShopInfoViewController new];
    editVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:editVC animated:YES];
}

#pragma mark -- 余额明细
- (void)goToDetails:(UIButton *)btn
{
    BalanceDetailController *detail = [BalanceDetailController new];
    detail.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:detail animated:YES];
}

#pragma mark -- 资金流水
- (void)capitalFlow:(UITapGestureRecognizer *)tap
{
    CapitalFlowController *flowVC = [CapitalFlowController new];
    flowVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:flowVC animated:YES];
}


- (void)adTap:(UITapGestureRecognizer *)tap
{
    WebViewController *webVC = [WebViewController new];
    NSDictionary *tipBanner = self.dict[@"tipsBanner"];
    webVC.urlString = [NSString stringWithFormat:@"%@",tipBanner[@"clickUrl"]];
    webVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:webVC animated:YES];
}

#pragma mark -- 订单
- (void)orderTap:(UITapGestureRecognizer *)tap
{
    OrderViewController *orderVC = [OrderViewController new];
    orderVC.hidesBottomBarWhenPushed = YES;
    orderVC.isFronze = self.isFronze;
    orderVC.buttionIdex = 0;
    [self.navigationController pushViewController:orderVC animated:YES];
}

- (void)goToOrderVC:(UIButton *)btn
{
    int index = (int)btn.tag - 199;
    OrderViewController *orderVC = [OrderViewController new];
    orderVC.hidesBottomBarWhenPushed = YES;
    orderVC.isFronze = self.isFronze;
    orderVC.buttionIdex = index;
    orderVC.amount = [NSString stringWithFormat:@"%.2f",[self.dict[@"orderRechargeAmount"]doubleValue]];
    [self.navigationController pushViewController:orderVC animated:YES];
}

#pragma mark -- 充值
- (void)rechargeBtn:(UIButton *)btn
{
    RechargeViewController *rechargeVC = [RechargeViewController new];
    rechargeVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:rechargeVC animated:YES];
}

- (void)selectBtn:(UIButton *)btn
{
    switch (btn.tag) {
        case 30:
        {
//            [self ShowHUDWithMessage:@"暂未开通，敬请期待"];
//            return;
            MyActivityController *activity = [MyActivityController new];
            activity.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:activity animated:YES];
            break;
        }
            
        case 31:
        {
            NSDictionary *dict = self.dict[@"shopInfo"];
            NSString *shopName = [NSString stringWithFormat:@"%@",dict[@"name"]];
            NSString *mobile = [NSString stringWithFormat:@"%@",dict[@"ownerMobile"]];

            NSString *url = [NSString stringWithFormat:@"http://im.7x24cc.com/phone_webChat.html?accountId=N000000013273&chatId=2e644976-9494-4a30-a4c5-7836c62b015c&nickName=[掌柜]%@-%@",shopName,mobile];
            NSLog(@"url-%@",url);
            WebViewController *webVC = [[WebViewController alloc]init];
            NSString *resultURL = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
            NSLog(@"resultURL-%@",resultURL);
            webVC.urlString = resultURL;
            webVC.isLoadHtml = YES;
            webVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:webVC animated:YES];
              break;
        }
            //隐藏公告
//        case 31:
//        {
//            AnnounceViewController *announceVC = [AnnounceViewController new];
//            announceVC.hidesBottomBarWhenPushed = YES;
//            [self.navigationController pushViewController:announceVC animated:YES];
//            break;
//        }
            
        case 32:
        {
            NSDictionary *dic = self.dict[@"shopInfo"];
            NSLog(@"跳转下城");
            WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
            launchMiniProgramReq.userName = @"gh_0307bfa8b637";  //拉起的小程序的username
            launchMiniProgramReq.path = [NSString stringWithFormat:@"page/index/index?sellerId=%@",dic[@"sellerId"]];//拉起小程序页面的可带参路径，不填默认拉起小程序首页
            launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
            [WXApi sendReq:launchMiniProgramReq];
            break;
        }
            
        case 33:
        {
            DownLoadCodeViewController *downLoadVC = [DownLoadCodeViewController new];
            downLoadVC.imageUrl = self.dict[@"offlinePayUrl"];
            downLoadVC.name = self.infoDict[@"name"];
            downLoadVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:downLoadVC animated:YES];
            break;
        }
            
        case 34:
        {
            SettingViewController *setVC = [SettingViewController new];
            setVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:setVC animated:YES];
            break;
        }
        default:
            break;
    }
}

@end
